FILE* fp = fopen("example.txt", "r");
if (fp == NULL) {
    printf("Failed to open file.\n");
    return -1;
}

char buffer[100];
size_t result = fread(buffer, 1, 10, fp);
if (result != 10) {
    if (ferror(fp)) {
        printf("Error reading file.\n");
    } else if (feof(fp)) {
        printf("End of file reached.\n");
    }
}

clearerr(fp);  // 清除错误标志

fclose(fp);
